#!/bin/bash
HIVE_HOME=/usr/bin/hive
yearstr=`date +%Y`
monthstr=`date +%m`
daystr=`date -d '-1 day' +%d`
#执行从ods->dwd
${HIVE_HOME} -S -e "
--开启动态分区
set hive.exec.dynamic.partition=true;
--设置非严格模式
set hive.exec.dynamic.partition.mode=nostrict;
--开启压缩模式
set hive.exec.orc.compression.strategy=COMPRESSION;
--开启中间压缩
set hive.exec.compress.intermediate=true;
--开启输出压缩
set hive.exec.compress.output=true;
insert into table macmillanedu_dwd.dwd_web_chat partition(yearinfo,quarterinfo,monthinfo,dayinfo)
SELECT  
unix_timestamp(wce.create_time,'yyyy-MM-dd HH:mm:ss') as create_time,
wce.session_id,
wce.sid,wce.ip,
wce.seo_source,
wce.area,
wce.country,
wce.province,
wce.city,
wce.origin_channel,
wce.msg_count,
wcte.referrer,
wcte.from_url,
wcte.landing_page_url,
wcte.url_title,
wcte.platform_description,
wcte.other_params,
wcte.history,
substr(wce.create_time,12,2) as hourinfo,
substr(wce.create_time,1,4) as yearinfo,
quarter(wce.create_time) as quarterinfo,
substr(wce.create_time,6,2) as monthinfo,
substr(wce.create_time,9,2) as dayinfo
from  macmillanedu_ods.web_chat_text_ems wcte 
JOIN (
select  *from macmillanedu_ods.web_chat_ems
where starts_time ='${yearstr}-${monthstr}-${daystr}'
)as wce 
on wce.id=wcte .id
"












